﻿@model ePrice.Models.Product
           
@{
    ViewBag.Title = "ProductManager";
}

<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

@{
    switch (ViewBag.Action as string)
    {
        case "Create":
            {
            <h2>Create</h2>
                using (Html.BeginForm())
                {
                @Html.ValidationSummary(true)
                <fieldset>
                    <legend>Product</legend>

                    <div class="editor-label">
                        @Html.LabelFor(model => model.ProductName)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.ProductName)
                        @Html.ValidationMessageFor(model => model.ProductName)
                    </div>

                    <div class="editor-label">
                        @Html.LabelFor(model => model.ProductCode)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.ProductCode)
                        @Html.ValidationMessageFor(model => model.ProductCode)
                    </div>

                    <div class="editor-label">
                        @Html.LabelFor(model => model.ProductFullName)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.ProductFullName)
                        @Html.ValidationMessageFor(model => model.ProductFullName)
                    </div>

                    <div class="editor-label">
                        @Html.LabelFor(model => model.ProductDescription)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.ProductDescription)
                        @Html.ValidationMessageFor(model => model.ProductDescription)
                    </div>

                    <div class="editor-label">
                        @Html.LabelFor(model => model.ProductImageURL)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.ProductImageURL)
                        @Html.ValidationMessageFor(model => model.ProductImageURL)
                    </div>

                    <div class="editor-label">
                        @Html.LabelFor(model => model.ProductThumbImage)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.ProductThumbImage)
                        @Html.ValidationMessageFor(model => model.ProductThumbImage)
                    </div>

                    <div class="editor-label">
                        @Html.LabelFor(model => model.ProductViewedCount)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.ProductViewedCount)
                        @Html.ValidationMessageFor(model => model.ProductViewedCount)
                    </div>

                    <div class="editor-label">
                        @Html.LabelFor(model => model.ProductLikedCount)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.ProductLikedCount)
                        @Html.ValidationMessageFor(model => model.ProductLikedCount)
                    </div>

                    <div class="editor-label">
                        @Html.LabelFor(model => model.ProductDislikedCount)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.ProductDislikedCount)
                        @Html.ValidationMessageFor(model => model.ProductDislikedCount)
                    </div>

                    <div class="editor-label">
                        @Html.LabelFor(model => model.ProductReviewerVoteAverage)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.ProductReviewerVoteAverage)
                        @Html.ValidationMessageFor(model => model.ProductReviewerVoteAverage)
                    </div>

                    <div class="editor-label">
                        @Html.LabelFor(model => model.ProductUserVoteAverage)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.ProductUserVoteAverage)
                        @Html.ValidationMessageFor(model => model.ProductUserVoteAverage)
                    </div>

                    <div class="editor-label">
                        @Html.LabelFor(model => model.ProductPriority)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.ProductPriority)
                        @Html.ValidationMessageFor(model => model.ProductPriority)
                    </div>

                    <div class="editor-label">
                        @Html.LabelFor(model => model.ManufactureId)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.ManufactureId)
                        @Html.ValidationMessageFor(model => model.ManufactureId)
                    </div>

                    <div class="editor-label">
                        @Html.LabelFor(model => model.CategoryId)
                    </div>
                    <div class="editor-field">
                        @Html.EditorFor(model => model.CategoryId)
                        @Html.ValidationMessageFor(model => model.CategoryId)
                    </div>

                    <p>
                        <input type="submit" value="Create" />
                    </p>
                </fieldset>
                }

            <div>
                @Html.ActionLink("Back to List", "Index")
            </div>
           break;
            }
        case "Edit":
            {
            if (Model == null)
            {
                <p>The product you request is not exist.
                <br />
                If you go here by typing url in browser' address bar, please double check the url
                <br />
                If not, it may be an error in server.
                <br />
                Click <a href="ProductManager">here</a> to return product manager home page
                </p>
                break;
            }
            <h2>Edit</h2>
            using (Html.BeginForm())
            {
            @Html.ValidationSummary(true)
            <fieldset>
                <legend>Product</legend>

                @Html.HiddenFor(model => model.ProductId)

                <div class="editor-label">
                    @Html.LabelFor(model => model.ProductName)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.ProductName)
                    @Html.ValidationMessageFor(model => model.ProductName)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.ProductCode)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.ProductCode)
                    @Html.ValidationMessageFor(model => model.ProductCode)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.ProductFullName)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.ProductFullName)
                    @Html.ValidationMessageFor(model => model.ProductFullName)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.ProductDescription)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.ProductDescription)
                    @Html.ValidationMessageFor(model => model.ProductDescription)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.ProductImageURL)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.ProductImageURL)
                    @Html.ValidationMessageFor(model => model.ProductImageURL)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.ProductThumbImage)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.ProductThumbImage)
                    @Html.ValidationMessageFor(model => model.ProductThumbImage)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.ProductViewedCount)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.ProductViewedCount)
                    @Html.ValidationMessageFor(model => model.ProductViewedCount)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.ProductLikedCount)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.ProductLikedCount)
                    @Html.ValidationMessageFor(model => model.ProductLikedCount)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.ProductDislikedCount)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.ProductDislikedCount)
                    @Html.ValidationMessageFor(model => model.ProductDislikedCount)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.ProductReviewerVoteAverage)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.ProductReviewerVoteAverage)
                    @Html.ValidationMessageFor(model => model.ProductReviewerVoteAverage)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.ProductUserVoteAverage)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.ProductUserVoteAverage)
                    @Html.ValidationMessageFor(model => model.ProductUserVoteAverage)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.ProductPriority)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.ProductPriority)
                    @Html.ValidationMessageFor(model => model.ProductPriority)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.CreatedTime)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.CreatedTime)
                    @Html.ValidationMessageFor(model => model.CreatedTime)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.LastModifiedTime)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.LastModifiedTime)
                    @Html.ValidationMessageFor(model => model.LastModifiedTime)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.ManufactureId)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.ManufactureId)
                    @Html.ValidationMessageFor(model => model.ManufactureId)
                </div>

                <div class="editor-label">
                    @Html.LabelFor(model => model.CategoryId)
                </div>
                <div class="editor-field">
                    @Html.EditorFor(model => model.CategoryId)
                    @Html.ValidationMessageFor(model => model.CategoryId)
                </div>

                <p>
                    <input type="submit" value="Save" />
                </p>
            </fieldset>
            }

            <div>
                @Html.ActionLink("Back to List", "Index")
            </div>
            break;
            }
        case "Delete":
            {
            <h2>Delete</h2>
    if (Model == null)
            {
                <p>The product you request is not exist.
                <br />
                If you go here by typing url in browser' address bar, please double check the url
                <br />
                If not, it may be an error in server.
                <br />
                Click <a href="ProductManager">here</a> to return product manager home page
                </p>
                break;
            }
                break;
            }
        case "Search":
            {
            <h2>Search</h2>
                break;
            }
        case "List":
            {
                <h2>List</h2>
                if ((ViewBag.List as List<ePrice.Models.Product>).Count == 0)
                {
                    <p>It seems our service is broken <br />
                    No product here
                    </p>
                    break;
                }
                else
                {
                    int count = 1;
                    foreach (ePrice.Models.Product product in ViewBag.List)
                    {
                        @count <br />
                        @product.ProductId
                        @product.ProductName
                    }
                    break;
                }
            }
        default:
            {
            <h2>Search</h2>
                break;
            }

    }
}